package cn.iocoder.yudao.module.bpm.api.amis.dto;

import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

@Data
@Schema(description = "AMIS【colum】组件配置信息")
@Builder
public class AmisListColumConfigDto implements Serializable {

    @Schema(description = "类型")
    private String type ;
    @Schema(description = "标题")
    private String title ;
    @Schema(description = "字段名")
    private String name ;
    @Schema(description = "占位符")
    private String placeholder ;
    @Schema(description = "是否显示")
    private Boolean visible ;
    @Schema(description = "格式化模板\n" +
            "type=【date】：默认值【YYYY-MM-DD】")
    private String format  ;
    @Schema(description = "json源数据")
    private JSONObject jsonConfig ;

    public String getFormat() {
        if("date".equals(this.type) && StringUtils.isBlank(this.format)){
            return "YYYY-MM-DD" ;
        }
        return format;
    }
}
